package com.xc.demo.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/checkEmail")
public class EmailController {

    @Resource
    private JavaMailSender jms; //自动注入bean

    @Resource
    private JavaMailSender ynw;

@GetMapping("/passShopper")
    public Boolean sendMail(@RequestParam String acceptMail){

//        建立邮箱消息
        SimpleMailMessage mailMessage = new SimpleMailMessage();
//        发送者
       mailMessage.setFrom("kuzxu18001983577@126.com");
//       接受者
    mailMessage.setTo(acceptMail);
//    发送的标题
    mailMessage.setSubject("益农网商家审核结果");
//    发送的内容
    mailMessage.setText("恭喜你，审核通过，快去使用系统吧！");
    jms.send(mailMessage);
    return true;

    }

    @GetMapping("/unPassShopper")
    public Boolean unPassMail(@RequestParam String acceptMail){

//        建立邮箱消息
        SimpleMailMessage mailMessage = new SimpleMailMessage();
//        发送者
        mailMessage.setFrom("kuzxu18001983577@126.com");
//       接受者
        mailMessage.setTo(acceptMail);
//    发送的标题
        mailMessage.setSubject("益农网商家审核结果");
//    发送的内容
        mailMessage.setText("抱歉，您上传的审核内容不通过，请重新上传！");
        ynw.send(mailMessage);
        return true;

    }





}
